---
import Disqus from './Disqus.astro'
import Giscus from './Giscus.astro'
import Twikoo from './Twikoo.astro'
interface Props {
  post: Post

}

const { id, data, slug } = Astro.props.post
const { comments } = Astro.locals.config

const path = `/posts/${slug}`
const url = `${Astro.site?.href}${path}`

let commentService = ''
if (comments && comments.disqus) {
  commentService = 'disqus'
} else if (comments && comments.giscus) {
  commentService = 'giscus'
} else if (comments && comments.twikoo) {
  commentService = 'twikoo'
}
---
<div py-16>
  {commentService === 'disqus' && <Disqus identifier={id} url={url} title={data.title} />}
  {commentService === 'giscus' && <Giscus />}
  {commentService === 'twikoo' && <Twikoo path={path} />}
  {commentService === '' && null}
</div>
